package utils

import (
	"github.com/micro/go-micro"
	"github.com/micro/go-micro/registry"
	"github.com/micro/go-micro/service/grpc"
	"github.com/micro/go-plugins/registry/consul"
)

///新建一个grpc服务
func NewGrpcService(serviceName string) micro.Service {
	reg := consul.NewRegistry(func(op *registry.Options) {
		op.Addrs = []string{
			GConsulAddr + ":" + GConsulPort,
		}
	})

	// New Service
	service := grpc.NewService(
		micro.Name(serviceName),
		micro.Version("latest"),
		micro.Registry(reg),
	)

	// Initialise service
	service.Init()

	return service
}
